<?php
defined("_VALID_ACCESS") || die('Direct access forbidden');
    class Eyeworx_ImportManager_ImportNew extends Module {

        public function body() {
            $form = &$this->init_module('Libs/QuickForm');
            $form->addElement('date', 'time_out', 'Time Out',array('format'=>'h:i a'));
            $form->addElement('submit', 'submit', 'Submit');

            if($form->isSubmitted()){
                $values = $form->exportValues();
                Libs_LeightboxCommon::close('pop-up');
            } else {
                $html = '<div>'.$form->toHtml().'</div>';
                $leightbox = Libs_LeightboxCommon::display('pop-up', $html, 'You forgot to time out!');
            }
        }

    }
?>

<?php

defined("_VALID_ACCESS") || die('Direct access forbidden');

class Accounting_Documents_Generator extends Module {

    public function body() {
        if ($this->isset_module_variable('wizard_to_display')) {
            $wiz = $this->get_module_variable('wizard_to_display');
            if ($wiz == 'pos') {
                echo '  <h2>POS Document Summary</h2>
			<table style="width:85%;margin:10px 10px 20px 10px;">
				<tr>
					<td style="font-weight: bold;">Source</td>
					<td>Sales Journal</td>
					<td style="font-weight: bold;">Sequence Number</td>
					<td><input type="text" value="SJ-00001" /></td>
					<td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Branch Alpha Code</td>
					<td>10 LTSS</td>
					<td style="font-weight: bold;">ARNOC</td>
					<td>2113</td>
					<td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Shift Number</td>
					<td><input type="text" value="1" /></td>
					<td></td><td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Document Date</td>
					<td><input type="text" value="mm-dd-yy" /></td>
					<td style="font-weight: bold;">Document Number</td>
					<td>POS&branch&date&shift</td>
					<td style="font-weight: bold;">Document</td>
					<td>POS</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Department Code</td>
					<td><select><option>Gas</option></select></td>
					<td style="font-weight: bold;">Product Class</td>
					<td>Gas</td>
					<td></td><td></td>
				</tr>
			</table>
			<table style="width:85%;margin:10px 10px 20px 10px;">
				<tr>
					<td style="font-weight: bold;">Manual Reading</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Wintas Reading</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Variance</td><td>liters</td><td>Gross Amount</td>
				</tr>
				<tr>
					<td></td><td></td><td></td>
					<td></td><td></td><td></td>
					<td></td><td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Sales</td><td></td><td></td>
					<td style="font-weight: bold;">Cash Sales</td><td></td><td>Gross Amount</td>
					<td style="font-weight: bold;">Sales Adjustments</td><td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">FS Diesel</td><td>liters</td><td>Gross Amount</td>
					<td></td><td></td><td></td>
					<td style="font-weight: bold;">Cash Discount</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">DOE Diesel</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Charge Sales</td><td></td><td></td>
					<td style="font-weight: bold;">Promo Discount</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">VPN Diesel</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">In-house</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Employee Charges</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">FS ULG</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Fleet Card</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Cash Shortage</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">VPN+</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">BDO Credit Card</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Fuel Expense-Genset</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">VPN + Racing</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">BPI Credit Card</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Fuel Expense-Motor Vehicles</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Total Sales</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Other Credit Card</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Representation Expense</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Sales Returns</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Total Charges</td><td>liters</td><td>Gross Amount</td>
					<td style="font-weight: bold;">Drawings-Fuel</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Adjusted Sales</td><td>liters</td><td>Gross Amount</td>
					<td></td><td></td><td></td>
					<td style="font-weight: bold;">Drawings-Cash</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td></td><td></td><td></td>
					<td></td><td></td><td></td>
					<td style="font-weight: bold;">Others</td><td></td><td>Gross Amount</td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Total Sales</td><td></td><td><input type="text" value="Gross Amount" /></td>
					<td style="font-weight: bold;">Total Cash and Charges</td><td></td><td><input type="text" value="Gross Amount" /></td>
					<td style="font-weight: bold;">Total Sales Adjustments</td><td></td><td><input type="text" value="Gross Amount" /></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Sales Variance</td><td></td><td><input type="text" value="total sales less total cash & charges less total adjustments" /></td>
					<td style="font-weight: bold;">Cash Variance</td><td></td><td><input type="text" value="total cash sales less adjustments less cash turnover per cash details" /></td>
					<td></td><td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Prepared by</td><td>Cashier Name</td><td></td>
					<td style="font-weight: bold;">Date Prepared</td><td>Date Time</td><td></td>
					<td></td><td></td><td></td>
				</tr>
				<tr>
					<td style="font-weight: bold;">Submitted by</td><td>Employee Name</td><td></td>
					<td style="font-weight: bold;">Date Submitted</td><td>Date Time</td><td></td>
					<td></td><td></td><td></td>
				</tr>
				<tr>
					<td></td><td></td><td></td>
					<td></td><td></td><td></td>
					<td></td><td></td><td></td>
				</tr>
			</table><hr/>
		';
                $wizard = $this->init_module('Utils/Wizard');
                $wizard->callback_page(array($this, 'readings'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'possales'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'salesdetails'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'paymentdetails'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'cashturnoverdetails'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'adjustmentdetails'));
                $wizard->next_page();
                $wizard->callback_page(array($this, 'journalentry'));
                $this->display_module($wizard, array(array($this, 'process_wizard')));
            }
        } else {
            Libs_LeightboxCommon::display('pos', $this->pos_choice());


            echo "<div style='width:700px;'><h1>Please choose a document to generate for this branch:</h1>";
            $document_types = Utils_CommonDataCommon::get_array('Accounting/DocumentTypes', TRUE);
            foreach ($document_types as $document_type) {
                if (strtoupper($document_type) == "POS") {
                    $pos_wizard_href = Libs_LeightboxCommon::get_open_href('pos');
                    echo "<a " . $pos_wizard_href . ">";
                }
                echo "<div class='epesi_big_button bigger' style='display:inline-block;'>
            <img src='data/Base_Theme/templates/default/Utils/Attachment/icon.png' border='0' width='32' height='32' align='middle'/>
            <span>$document_type</span>
        </div>";
                if (strtoupper($document_type) == "POS") {
                    echo "</a>";
                }
            }
            echo "</div>";
            Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
        }
    }

    public function pos_choice() {
        $pos_wizard_href = $this->create_callback_href(array($this, 'pos_wizard'));
        return "<center><h1>Please choose department type:</h1><a $pos_wizard_href><div class='epesi_big_button bigger' style='display:inline-block;'>
            <img src='data/Base_Theme/templates/default/Utils/Attachment/icon.png' border='0' width='32' height='32' align='middle'/>
            <span>Gas</span>
        </div></a><div class='epesi_big_button bigger' style='display:inline-block;'>
            <img src='data/Base_Theme/templates/default/Utils/Attachment/icon.png' border='0' width='32' height='32' align='middle'/>
            <span>Shop</span>
        </div><div class='epesi_big_button bigger' style='display:inline-block;'>
            <img src='data/Base_Theme/templates/default/Utils/Attachment/icon.png' border='0' width='32' height='32' align='middle'/>
            <span>Manual</span>
        </div></center>";
    }

    public function pos_wizard() {
        Libs_LeightboxCommon::close('pos');
        $this->set_module_variable('wizard_to_display', 'pos');
    }

    public function readings() {
        echo "<h2>Gas Readings</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Hose ID</td>
                    <td style='background-color:black;color:white;'>Product Code</td>
                    <td style='background-color:black;color:white;'>Grade</td>
                    <td style='background-color:black;color:white;'>Pump Price</td>
                    <td style='background-color:black;color:white;'>Read Beginning</td>
                    <td style='background-color:black;color:white;'>Read Ending</td>
                    <td style='background-color:black;color:white;'>Manual Volume</td>
                    <td style='background-color:black;color:white;'>Volume Adjustment</td>
                    <td style='background-color:black;color:white;'>Wintas Volume</td>
                    <td style='background-color:black;color:white;'>Wintas Sales</td>
                    <td style='background-color:black;color:white;'>Volume Variance</td>
                    <td style='background-color:black;color:white;'>Sales Variance</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>wewq123</td>
                    <td>33</td>
                    <td>232</td>
                    <td>2321</td>
                    <td><input type='text'/></td>
                    <td></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td></td>
                    <td></td>
                </tr>
                <tr>
                    <td>2</td>
                    <td>wewq123</td>
                    <td>33</td>
                    <td>232</td>
                    <td>2321</td>
                    <td><input type='text'/></td>
                    <td></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td></td>
                    <td></td>
                </tr>
            </table>
        ";
    }

    public function possales() {
        echo "<h2>POS Sales</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Product AC</td>
                    <td style='background-color:black;color:white;'>Product Description</td>
                    <td style='background-color:black;color:white;'>Revenue Code</td>
                    <td style='background-color:black;color:white;'>Quantity</td>
                    <td style='background-color:black;color:white;'>UM</td>
                    <td style='background-color:black;color:white;'>Amount VAT Incl.</td>
                </tr>
                <tr>
                    <td>5001 VPN+R</td>
                    <td>Vpower</td>
                    <td>411</td>
                    <td><input type='text'/></td>
                    <td>liters</td>
                    <td><input type='text'/></td>
                </tr>
                <tr>
                    <td>5001 VPN+R</td>
                    <td>Vpower</td>
                    <td>411</td>
                    <td><input type='text'/></td>
                    <td>liters</td>
                    <td><input type='text'/></td>
                </tr>
            </table>
        ";
    }

    public function salesdetails() {
        echo "<h2>Sales Details</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>VAT Transaction AC</td>
                    <td style='background-color:black;color:white;'>Transaction Name</td>
                    <td style='background-color:black;color:white;'>Vendee Code</td>
                    <td style='background-color:black;color:white;'>Name</td>
                    <td style='background-color:black;color:white;'>Tin</td>
                    <td style='background-color:black;color:white;'>Amount VAT Incl.</td>
                    <td style='background-color:black;color:white;'>VAT</td>
                    <td style='background-color:black;color:white;'>Amount VAT Excl.</td>
                </tr>
                <tr>
                    <td><select><option>301 VSP</option></select></td>
                    <td><select><option>Sales to Private</option></select></td>
                    <td><select><option>Vendee Code</option></select></td>
                    <td><select><option>Vendee Name</option></select></td>
                    <td>000-000-000-0000</td>
                    <td><input type='text'/></td>
                    <td>0</td>
                    <td>0</td>
                </tr>
                <tr>
                  <td><select><option>301 VSP</option></select></td>
                    <td><select><option>Sales to Government</option></select></td>
                    <td><select><option>Vendee Code</option></select></td>
                    <td><select><option>Vendee Name</option></select></td>
                    <td>000-000-000-0000</td>
                    <td><input type='text'/></td>
                    <td>0</td>
                    <td>0</td>
                </tr>
            </table>
        ";
    }

    public function paymentdetails() {
        echo "<h2>Payment Details</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Vendee AC</td>
                    <td style='background-color:black;color:white;'>Name</td>
                    <td style='background-color:black;color:white;'>Payment Mode Code</td>
                    <td style='background-color:black;color:white;'>Reference Number</td>
                    <td style='background-color:black;color:white;'>PO Number</td>
                    <td style='background-color:black;color:white;'>Plate Number</td>
                    <td style='background-color:black;color:white;'>Product Description</td>
                    <td style='background-color:black;color:white;'>Quantity</td>
                       <td style='background-color:black;color:white;'>UOM</td>
                         <td style='background-color:black;color:white;'>Gross Amount</td>
                </tr>
                <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
              <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
            </table>
        ";
    }

    public function cashturnoverdetails() {
        echo "<h2>Cashturnover Details</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Vendee AC</td>
                    <td style='background-color:black;color:white;'>Name</td>
                    <td style='background-color:black;color:white;'>Payment Mode Code</td>
                    <td style='background-color:black;color:white;'>Reference Number</td>
                    <td style='background-color:black;color:white;'>PO Number</td>
                    <td style='background-color:black;color:white;'>Plate Number</td>
                    <td style='background-color:black;color:white;'>Product Description</td>
                    <td style='background-color:black;color:white;'>Quantity</td>
                       <td style='background-color:black;color:white;'>UOM</td>
                         <td style='background-color:black;color:white;'>Gross Amount</td>
                </tr>
                <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
              <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
            </table>
        ";
    }

    public function adjustmentdetails() {
        echo "<h2>Adjustment Details</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Vendee AC</td>
                    <td style='background-color:black;color:white;'>Name</td>
                    <td style='background-color:black;color:white;'>Payment Mode Code</td>
                    <td style='background-color:black;color:white;'>Reference Number</td>
                    <td style='background-color:black;color:white;'>PO Number</td>
                    <td style='background-color:black;color:white;'>Plate Number</td>
                    <td style='background-color:black;color:white;'>Product Description</td>
                    <td style='background-color:black;color:white;'>Quantity</td>
                       <td style='background-color:black;color:white;'>UOM</td>
                         <td style='background-color:black;color:white;'>Gross Amount</td>
                </tr>
                <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
              <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
            </table>
        ";
    }

    public function journalentry() {
        echo "<h2>Journal Entry</h2>
            <table style='width:85%;margin:10px 10px 20px 10px;'>
                <tr>
                    <td style='background-color:black;color:white;'>Vendee AC</td>
                    <td style='background-color:black;color:white;'>Name</td>
                    <td style='background-color:black;color:white;'>Payment Mode Code</td>
                    <td style='background-color:black;color:white;'>Reference Number</td>
                    <td style='background-color:black;color:white;'>PO Number</td>
                    <td style='background-color:black;color:white;'>Plate Number</td>
                    <td style='background-color:black;color:white;'>Product Description</td>
                    <td style='background-color:black;color:white;'>Quantity</td>
                       <td style='background-color:black;color:white;'>UOM</td>
                         <td style='background-color:black;color:white;'>Gross Amount</td>
                </tr>
                <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
              <tr>
                    <td><select><option>PCode</option></select></td>
                    <td><select><option>Name</option></select></td>
                    <td>Cash</td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><input type='text'/></td>
                    <td><select><option>Description</option></select></td>
                     <td><input type='text'/></td>
                      <td><input type='text'/></td>
                       <td><input type='text'/></td>
                </tr>
            </table>
        ";
    }

    public function process_wizard($data) {
        Base_StatusBarCommon::message('POS Document Sent - reloading page');
        eval_js('setTimeout(\'document.location=\\\'index.php\\\'\',\'3000\')');
    }

}